package com.cloudsigns.factorymanager2.engineering.presenter;

import com.cloudsigns.factorymanager2.engineering.activity.InTeamMaintainOrderListView;
import com.cloudsigns.factorymanager2.engineering.bean.OrderParentBean;
import com.cloudsigns.factorymanager2.engineering.model.InTeamMaintainOrderListModel;
import com.cloudsigns.factorymanager2.engineering.model.TeamMaintainOrderListModel;

import java.util.List;

/**
 * Created by tony on 2018/5/19.
 */

public class TeamMaintainOrderListPresenter {
    private InTeamMaintainOrderListView view;
    private InTeamMaintainOrderListModel model;
    private android.os.Handler mHandler = new android.os.Handler();

    public TeamMaintainOrderListPresenter(InTeamMaintainOrderListView view) {
        this.view = view;
        this.model = new TeamMaintainOrderListModel();
    }

    public void getTeamMaintainOrderList() {
        view.showLoading();

        model.getTeamMaintainOrderList(new TeamMaintainOrderListModel.OnTeamMaintainOrderListener() {
            @Override
            public void getTeamMaintainOrderListSuceesed(final List<OrderParentBean> orderParentBeanList) {
                //需要在UI线程执行
                mHandler.post(new Runnable() {
                    @Override
                    public void run() {
                        view.getTeamMaintainOrderListSuccessed(orderParentBeanList);
                        view.hideLoading();
                    }
                });
            }

            @Override
            public void getTeamMaintainOrderListFailed(final String desc) {
                mHandler.post(new Runnable() {
                    @Override
                    public void run() {
                        view.getTeamMaintainOrderListFailed(desc);
                        view.hideLoading();
                    }
                });
            }


        });
    }
}
